<%@ page language="java" contentType="text/xml; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="java.util.List"%>
<%@page import="br.com.rapidrest.demo.domain.PhoneEntry"%>
<jsp:useBean id="bean" scope="request" class="br.com.rapidrest.demo.web.engine.phonebook.ViewPhoneBook" /> 
<engine xmlns:hl="http://www.holyavenger.org/holyavenger/1.0">
	<action id="content">
		<h1><%=bean.getMessages().get("title")%></h1>
		<h2><%=bean.getMessages().get("viewPhoneBook")%></h2>
		
		<h3><%=bean.getPhoneBook().getName()%></h3>
		
		<%
		List<PhoneEntry> entries = bean.getEntries();
		%>
		
		<h3><%=bean.getMessages().get("phoneBookEntries")%></h3>
		<table title="<%=bean.getMessages().get("phoneBookEntries")%>">
			<thead>
				<tr>
					<th><%=bean.getMessages().get("name")%></th>
					<th><%=bean.getMessages().get("phone")%></th>
				</tr>
			</thead>
			<tbody>
			<%
			if (entries.isEmpty()) {
			%>
				<tr>
					<td colspan="2"><%=bean.getMessages().get("noRegisteredEntries")%></td>
				</tr>
			<%
			} else {
				for (PhoneEntry entry : entries) {
			%>
				<tr>
					<td><%=entry.getName()%></td>
					<td><%=entry.getPhone()%></td>
				</tr>
			<%
				}
			}
			%>
			</tbody>
		</table>
		
		<a href="#engine/Home" title="<%=bean.getMessages().get("back")%>">
			<%=bean.getMessages().get("back")%>
		</a>
	</action>
</engine>